package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.GetComDoctorRequest;
import keeto.com.vn.bms.network.request.GetComDoctorResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskGetComDoctor extends AbstractTask {
	String authenKey;
	String comId;
	String Date;
	public TaskGetComDoctor(BMSListener listener, IBMSCore core,String authKey,String Date,String comid) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey=authKey;
		this.comId=comid;
		this.Date=Date;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		GetComDoctorRequest request= new GetComDoctorRequest();
		request.setAuthenKey(authenKey);
		request.setComId(comId);
		request.setDate(Date);
		GetComDoctorResponse response= protocol.getComDoctor(request);
		for(BMSListener mListener:listener){
			mListener.finishGetComDoctor(response.getReturnCode(), response.getResultMsg(), response.getListDocttor());
		}
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishGetComDoctor(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "Failed", null);
		}
	}

}
